<template>
	<PageContainer name="浏览记录">
		<template #header-right>
			<text class="global-text-button" @click="clearHistory">清空记录</text>
		</template>
		<view class="history-container">
			<ScrollList :list="historyList">
				<template v-for="item in historyList">
					
				</template>
			</ScrollList>
		</view>
	</PageContainer>
</template>

<script>
	import store from '@/store';
	import {
		getHistory,
		removeHistory,
	} from '@/utils/history.js';
	import PageContainer from '@/components/PageContainer/PageContainer.vue';
	import ScrollList from '@/components/ScrollList/index.vue';
	export default {
		components: {
			PageContainer,
			ScrollList,
		},
		computed: {
			isHr() {
				const {
					user
				} = store.state;
				return user.type === '1';
			}
		},
		data() {
			return {
				historyList: []
			}
		},
		methods: {
			clearHistory() {
				if (!this.historyList.length) {
					uni.showToast({
						title: '暂无浏览记录',
						icon: 'none',
					})
					return;
				}
				uni.showModal({
					title: '温馨提示',
					content: '确定清空记录吗？',
					success: (res) => {
						if (res.cancel) {
							return;
						}
						removeHistory();
						this.getList();
					}
				})

			},
			getList() {
				const list = getHistory();
				this.historyList = list;
			}
		},
		onLoad() {
			this.getList();
		}
	}
</script>

<style scoped lang="scss">
	.history-container {
		padding: 30rpx 0;
	}
</style>